'''
细粒度图像识别
'''
import base64

import requests


def get_ingredient():
    request_url = "https://aip.baidubce.com/rest/2.0/image-classify/v1/classify/ingredient"
    # 二进制方式打开图片文件
    f = open('[本地文件]', 'rb')
    img = base64.b64encode(f.read())

    params = {"image":img}
    access_token = '[调用鉴权接口获取的token]'
    request_url = request_url + "?access_token=" + access_token
    headers = {'content-type': 'application/x-www-form-urlencoded'}
    response = requests.post(request_url, data=params, headers=headers)
    if response:
        print (response.json())